/**
 * Created by charry on 2016/6/27.
 */

//首页banner图集展示插件
$.fn.IndexCarousel_c = function (options) {
	var settings = {
		speed: 1000,//动画执行过程的时间
		time: 3000,//动画循环的等待时间
		classname: 'on',//切换序号标识添加的class
		switchover: 'display', //    'display'   'fade'  'acrossRoll'  'leftRoll'   'rightRoll'  'verticalRoll'   'topRoll'   'bottomRoll'
		emDisplay: true, //序号em是否显示，默认显示true，关掉则=false
		page: true, // 是否显示左右切换按钮
		page_prev: '.prev',
		page_next: '.next',
		onmouseup: null //鼠标松开的回调函数
	};
	$.extend(true, settings, options);
	return this.each(function () {
		var $this = $(this),
			$Width = $this.width(),//获取宽度
			$Height = $this.height(),//获取高度
			$ul = $this.children('ul'),
			$li = $ul.children('li'),
			$span = $this.find('.mod-newsDescSpan'),
			//$span = $this.children('div').children('span'),
			$liLength = $li.length,//li的数量
			pageSign = 0,// 翻页执行标记
			intervalTime,//动画的间隔时间
			index = 0,//码数默认=0
			changeTime = null,//创建定时器
			direction = 1,//循环切换的方向
			emIndex,//em用的记数
			$em,//em本身
			emHtml='';//存放em的HTML
		//重置基础CSS属性
		$this.css({ "position": "relative", "overflow": "hidden" });
		$ul.css({ "position": "absolute", "left": "440px", "top": "0" })
			.children('li').css({ "width": $Width, "height": $Height, "overflow": "hidden" });
		//各个切换模式的CSS默认设置
		if (settings.switchover == 'display') {
			$li.css({ "float": 'none' }).not($li.first()).hide();
			settings.speed = 0;
		} else if (settings.switchover == 'fade') {
			$li.css({ "float": 'none', "position": "absolute", "left": "0px", "top": "0", "opacity": '0', "z-index": '1' }).first().css({ "z-index": '2', "opacity": '1' });
		} else if (settings.switchover == 'acrossRoll') {
			$ul.css({ "width": $Width * $liLength })
			$li.css({ "float": 'left' });
		} else if (settings.switchover == 'leftRoll') {
			$ul.css({ "width": $Width * ($liLength * 1 + 1) }).append($li.first().clone());
			$ul.children('li').css({ "float": 'left' });
		} else if (settings.switchover == 'rightRoll') {
			$ul.css({ "width": $Width * ($liLength * 1 + 1), "left": $Width * (-1) * $liLength }).append($li.first().clone());
			$ul.children('li').css({ "float": 'left' });
			for (var i = 0; i < $liLength + 1; i++) { $ul.prepend($ul.children('li').eq(i)); }//倒序处理
		} else if (settings.switchover == 'verticalRoll') {
			$ul.css({ "width": $Width})
			$li.css({ "float": 'none' });
		} else if (settings.switchover == 'topRoll') {
			$ul.append($li.first().clone());
		} else if (settings.switchover == 'bottomRoll') {
			$ul.css({ "width": $Width , "top": $Height * (-1) * $liLength }).append($li.first().clone());
			for (var i = 0; i < $liLength + 1; i++) { $ul.prepend($ul.children('li').eq(i)); }//倒序处理
		}
		//设置间隔时间
		intervalTime = settings.time + settings.speed;
		//重置$em
		if (settings.emDisplay) {
			for (var i = 0; i < $liLength; i++) {
				var j=$liLength-1-i;
				var $txt = $li.find("h3").eq(j).html();
				var $timerTxt = $li.find("p").eq(j).html();
				emHtml += "<div class='news-descInfo'><em>"+(i*1+1)+"</em><h3>"+$txt+"</h3><p class='newsTimer'>"+$timerTxt+"<p/></div>";
			}
			$span.append(emHtml);
			$em = $span.children('.news-descInfo');
			$em.eq(0).addClass(settings.classname);
		}
		//各个切换状态的调用方法
		function display_fn(_index) {//切换
			$li.eq(_index).css('display', 'block').siblings().hide();
			if (settings.emDisplay) { $em.eq(_index).addClass(settings.classname).siblings().removeClass(settings.classname); }
		}
		function fade_fn(_index) {//渐变
			$li.eq(_index).stop().fadeTo(settings.speed, 1, function () {
				$(this).css({ "z-index": '2' })
			}).siblings().stop().fadeTo(settings.speed, 0, function () {
				$(this).css({ "z-index": '1' })
			});
			if (settings.emDisplay) { $em.eq(_index).addClass(settings.classname).siblings().removeClass(settings.classname); }
		}
		function acrossRoll_fn(_index) {//横向左右循环
			$ul.stop().animate({ "left": _index * $Width * (-1) }, settings.speed, function () { pageSign = 0; });
			if (settings.emDisplay) { $em.eq(_index).addClass(settings.classname).siblings().removeClass(settings.classname); }
		}
		function leftRoll_fn(_index) {//左循环
			if (_index == $liLength) { emIndex = 0; } else { emIndex = _index; }
			$ul.stop().animate({ "left": _index * (-1) * $Width }, settings.speed, function () { pageSign = 0; });
			if (settings.emDisplay) { $span.children('.news-descInfo').eq(emIndex).addClass(settings.classname).siblings().removeClass(settings.classname); }
		}
		function rightRoll_fn(_index) {//右循环
			if (_index == $liLength) { emIndex = 0; } else { emIndex = _index; }
			$ul.stop().animate({ "left": ($liLength - _index) * (-1) * $Width }, settings.speed, function () { pageSign = 0; });
			if (settings.emDisplay) { $span.children('.news-descInfo').eq(emIndex).addClass(settings.classname).siblings().removeClass(settings.classname); }
		}
		function verticalRoll_fn(_index) {//竖向上下循环
			$ul.stop().animate({ "top": _index * $Height * (-1) }, settings.speed, function () { pageSign = 0; });
			if (settings.emDisplay) { $em.eq(_index).addClass(settings.classname).siblings().removeClass(settings.classname); }
		}
		function topRoll_fn(_index) {//上循环
			if (_index == $liLength) { emIndex = 0; } else { emIndex = _index; }
			$ul.stop().animate({ "top": _index * (-1) * $Height }, settings.speed, function () { pageSign = 0; });
			if (settings.emDisplay) {$span.children('.news-descInfo').eq(emIndex).addClass(settings.classname).siblings().removeClass(settings.classname);}
		}
		function bottomRoll_fn(_index) {//下循环
			if (_index == $liLength) { emIndex = 0; } else { emIndex = _index; }
			$ul.stop().animate({ "top": ($liLength - _index) * (-1) * $Height }, settings.speed, function () { pageSign = 0; });
			if (settings.emDisplay) { $span.find('.news-descInfo').eq(emIndex).addClass(settings.classname).siblings().removeClass(settings.classname); }
		}
		//定时器调用的轮播切换的方法
		function Time() {
			if (settings.switchover == 'display') {
				if (index == $liLength - 1) { index = 0; } else { index = index + 1; }
				display_fn(index);
			}else if (settings.switchover == 'fade') {
				if (index == $liLength - 1) { index = 0; } else { index = index + 1; }
				fade_fn(index);
			} else if (settings.switchover == 'acrossRoll') {
				if (index == $liLength - 1) { direction = -1; } else if (index == 0) { direction = 1 }
				index = index + direction;
				acrossRoll_fn(index);
			} else if (settings.switchover == 'leftRoll') {
				if (index == $liLength) {index = 0;$ul.css("left", 0);}
				index = index + 1;
				leftRoll_fn(index);
			} else if (settings.switchover == 'rightRoll') {
				if (index == $liLength) { index = 0; $ul.css("left", $Width * (-1) * $liLength); }
				index = index + 1;
				rightRoll_fn(index);
			}else if (settings.switchover == 'verticalRoll') {
				if (index == $liLength - 1) { direction = -1; } else if (index == 0) { direction = 1 }
				index = index + direction;
				verticalRoll_fn(index);
			} else if (settings.switchover == 'topRoll') {
				if (index == $liLength) { index = 0; $ul.css("top", 0); }
				index = index + 1;
				topRoll_fn(index);
			} else if (settings.switchover == 'bottomRoll') {
				if (index == $liLength) { index = 0; $ul.css("top", $Height * (-1) * $liLength); }
				index = index + 1;
				bottomRoll_fn(index);
			}
		}

		if ($liLength > 1) {
			//开启定时器
			changeTime = setInterval(Time, intervalTime);
			//鼠标移入移出序号点的切换
			if (settings.emDisplay) {
				$em.mouseover(function () {
					clearInterval(changeTime);
					index = $(this).index()-1;
					if (settings.switchover == 'display') {
						display_fn(index);
					} else if (settings.switchover == 'fade') {
						fade_fn(index);
					} else if (settings.switchover == 'acrossRoll') {
						acrossRoll_fn(index);
					} else if (settings.switchover == 'leftRoll') {
						leftRoll_fn(index);
					} else if (settings.switchover == 'rightRoll') {
						rightRoll_fn(index);
					} else if (settings.switchover == 'verticalRoll') {
						verticalRoll_fn(index);
					} else if (settings.switchover == 'topRoll') {
						topRoll_fn(index);
					} else if (settings.switchover == 'bottomRoll') {
						bottomRoll_fn(index);
					}
				}).mouseout(function () {
					changeTime = setInterval(Time, intervalTime);
				});
			}
			//下一页翻页的设置
			if (settings.page) {
				//翻页点击切换
				function pageClick(pageDirection) {  //pageDirection=‘prev’ ||'next'
					var index_1, index_2, num_1, num_2;
					if (pageDirection == 'next') {
						index_1 = $liLength - 1;
						index_2 = 0;
						num_1 = 1;
						num_2 = -1;
					} else if (pageDirection == 'prev') {
						index_1 = 0;
						index_2 = $liLength - 1;
						num_1 = -1;
						num_2 = 1;
					}
					if (settings.switchover == 'display') {
						if (index == index_1) { index = index_2; } else { index = index + num_1; }
						display_fn(index);
					} else if (settings.switchover == 'fade') {
						if (index == index_1) { index = index_2; } else { index = index + num_1; }
						fade_fn(index);
					} else if (settings.switchover == 'acrossRoll') {
						if (pageSign == 0) {
							pageSign = 1;
							if (index == index_1) { pageSign = 0; return false; } else { index = index + num_1 }
							acrossRoll_fn(index);
						}
					} else if (settings.switchover == 'leftRoll') {
						if (pageSign == 0) {
							pageSign = 1;
							if (pageDirection == 'next') {
								if (index == $liLength) { index = 0; $ul.css("left", 0); }
							} else if (pageDirection == 'prev') {
								if (index == 0) { index = $liLength; $ul.css("left", ($liLength) * -1 * $Width); }
							}
							index = index + num_1;
							leftRoll_fn(index);
						}
					} else if (settings.switchover == 'rightRoll') {
						if (pageSign == 0) {
							pageSign = 1;
							if (pageDirection == 'next') {
								if (index == $liLength) { index = 0; $ul.css("left", $Width * (-1) * $liLength); }
							} else if (pageDirection == 'prev') {
								if (index == 0) { index = $liLength; $ul.css("left", 0); }
							}
							index = index + num_1;
							rightRoll_fn(index);
						}
					} else if (settings.switchover == 'verticalRoll') {
						if (pageSign == 0) {
							pageSign = 1;
							if (index == index_1) { pageSign = 0; return false; } else { index = index + num_1; }
							verticalRoll_fn(index);
						}
					} else if (settings.switchover == 'topRoll') {
						if (pageSign == 0) {
							pageSign = 1;
							if (pageDirection == 'next') {
								if (index == $liLength) { index = 0; $ul.css("top", 0); }
							} else if (pageDirection == 'prev') {
								if (index == 0) { index = $liLength; $ul.css("top", ($liLength) * -1 * $Height); }
							}
							index = index + num_1;
							topRoll_fn(index);
						}
					} else if (settings.switchover == 'bottomRoll') {
						if (pageSign == 0) {
							pageSign = 1;
							if (pageDirection == 'next') {
								if (index == $liLength) { index = 0; $ul.css("top", $Height * (-1) * $liLength); }
							} else if (pageDirection == 'prev') {
								if (index == 0) { index = $liLength; $ul.css("top", 0); }
							}
							index = index + num_1;
							bottomRoll_fn(index);
						}
					}
				}
				//下一页翻页的设置
				$this.children(settings.page_next).show().attr('href', 'javascript:void(0)').mouseover(function () {
					clearInterval(changeTime);
				}).mouseout(function () {
					changeTime = setInterval(Time, intervalTime);
				}).click(function () {
					pageClick('next');
				});
				//上一页翻页的设置
				$this.children(settings.page_prev).show().attr('href', 'javascript:void(0)').mouseover(function () {
					clearInterval(changeTime);
				}).mouseout(function () {
					changeTime = setInterval(Time, intervalTime);
				}).click(function () {
					pageClick('prev');
				});
			} else {
				$this.children(settings.page_next).hide();
				$this.children(settings.page_prev).hide();
			}
			//鼠标移入移出图片上关闭开启轮播切换
			$ul.children('li').hover(function () {clearInterval(changeTime);},
				function () {changeTime = setInterval(Time, intervalTime);});
		}
	});
};

/*头条新闻功能*/
$(".j-topNews .topNews-timer").on('click',function(){
	$(this).parent().addClass("current");
	$(this).parent().siblings().removeClass("current");
	$(".j-topNews .topNews-tps").stop().animate({width:"0"});
	$(this).siblings().stop().animate({width:"300px"});
})
/*$(".j-topNews .topNews-timer").each(function(){
	$(this).hover(function(){
		$(".j-topNews .topNews-timer").removeClass("fn-dn");
		$(".j-topNews .topNews-tps").addClass("fn-dn");
		$(this).addClass("fn-dn");
		$(this).siblings().removeClass("fn-dn");
	})
})*/

/*新闻列表图片鼠标事件*/
var $setTimer;
/*$(".mod-ListFloat li").hover(function(){
	var $Dkey = $(this).attr("data-key");
	var $ShowHeight = $(this).find(".mod-ListImg-dersc").outerHeight();
	var $ShowHtml = $(this).find(".mod-ListImg-dersc").html();
	var This =$(this);
	if($ShowHtml!=""){
		$setTimer = setTimeout(function(){
			if($Dkey=="t"){
				This.find(".mod-ListImg-dersc").slideDown();
			}
		},300);
	}	
},function(){
	var $Dkey = $(this).attr("data-key");
	clearTimeout($setTimer);
	if($Dkey=="t") {
		$(this).find(".mod-ListImg-dersc").stop().slideUp();
	}
})*/
$(".mod-ListFloat li").hover(function(){
	var $Dkey = $(this).attr("data-key");
	var $ShowHeight = $(this).find(".mod-ListImg-dersc").outerHeight();
	var $ShowHtml = $(this).find(".mod-ListImg-dersc").html();
	var This =$(this);
	//if($ShowHtml!=""){
		$setTimer = setTimeout(function(){
			if($Dkey=="t"){
				This.addClass("fn-pr");
				This.find(".mod-ListImg-dersc").css({"height":"100%"});
				var $dataHd = This.find(".mod-ListImg-hd").clone();
				var $dataBd = This.find(".mod-ListImg-info").clone();
				This.find(".cloneCover").html($dataHd).removeClass("fn-dn");
				This.find(".cloneCover").append($dataBd);
				This.find(".cloneCover").stop().animate({
					height:"100%",
					top:"0"
						});
			}
		},300);
	//}	
},function(){
	var $Dkey = $(this).attr("data-key");
	clearTimeout($setTimer);
	if($Dkey=="t") {
		$(this).find(".cloneCover").stop().animate({
			height:"0",
			top:"379px"
				});
		$(this).find(".cloneCover").empty();
	}
});


/*回到顶部*/
$(".go-top a").on('click',function(){
	$('body,html').animate({scrollTop:0},800);
});
$(window).scroll(function(){
	var sh=$(this).scrollTop();
	if(sh>40){
		$('.go-top').fadeIn(500);
	}else{
		$('.go-top').fadeOut(500);
	}
});

//上一图片
$(".j-showImgItems").on('click',function(){
	$(".mainContent").removeClass("fn-dn");
	$(".newsImg-suggest").addClass("fn-dn");
});
//最后一个图片
$(".j-sohwEndList").on('click',function(){
	$(".mainContent").addClass("fn-dn");
	$(".newsImg-suggest").removeClass("fn-dn");
})
//新闻内页图片插件
$.fn.newsImg_Carousel = function (options) {
	var settings = {
		speed: 1000,//动画执行过程的时间
		time: 3000,//动画循环的等待时间
		classname: 'current',//切换序号标识添加的class
		switchover: 'display', //    'display'   'fade'  'acrossRoll'  'leftRoll'   'rightRoll'  'verticalRoll'   'topRoll'   'bottomRoll'
		emDisplay: true, //序号em是否显示，默认显示true，关掉则=false
		page: true, // 是否显示左右切换按钮
		page_prev: '.prev',
		page_next: '.next',
		auto:true,  //是否自定义滑动，默认显示true，关掉则=false
		onmouseup: null //鼠标松开的回调函数
	};
	$.extend(true, settings, options);
	return this.each(function () {
		var $this = $(this),
			$Width = $this.width(),//获取宽度
			$Height = $this.height(),//获取高度
			$ul = $this.children('ul'),
			$li = $ul.children('li'),
			$span = $('#photoList ul'),
			$liLength = $li.length,//li的数量
			pageSign = 0,// 翻页执行标记
			intervalTime,//动画的间隔时间
			index = 0,//码数默认=0
			changeTime = null,//创建定时器
			direction = 1,//循环切换的方向
			emIndex,//em用的记数
			$em,//em本身
			emHtml='';//存放em的HTML
		//重置基础CSS属性
		$this.css({ "position": "relative", "overflow": "hidden" });
		$ul.css({ "position": "absolute", "left": "50%", "top": "0", "margin-left":-($Width-20)/2 })
			.children('li').css({ "width": $Width-20, "height": $Height, "overflow": "hidden" });
		//各个切换模式的CSS默认设置
		if (settings.switchover == 'display') {
			$li.css({ "float": 'none' }).not($li.first()).hide();
			settings.speed = 0;
		} else if (settings.switchover == 'fade') {
			$li.css({ "float": 'none', "position": "absolute", "left": "0px", "top": "0", "opacity": '0', "z-index": '1' }).first().css({ "z-index": '2', "opacity": '1' });
		} else if (settings.switchover == 'acrossRoll') {
			$ul.css({ "width": $Width * $liLength })
			$li.css({ "float": 'left' });
		} else if (settings.switchover == 'leftRoll') {
			$ul.css({ "width": $Width * ($liLength * 1 + 1) }).append($li.first().clone());
			$ul.children('li').css({ "float": 'left' });
		} else if (settings.switchover == 'rightRoll') {
			$ul.css({ "width": $Width * ($liLength * 1 + 1), "left": $Width * (-1) * $liLength }).append($li.first().clone());
			$ul.children('li').css({ "float": 'left' });
			for (var i = 0; i < $liLength + 1; i++) { $ul.prepend($ul.children('li').eq(i)); }//倒序处理
		} else if (settings.switchover == 'verticalRoll') {
			$ul.css({ "width": $Width})
			$li.css({ "float": 'none' });
		} else if (settings.switchover == 'topRoll') {
			$ul.append($li.first().clone());
		} else if (settings.switchover == 'bottomRoll') {
			$ul.css({ "width": $Width , "top": $Height * (-1) * $liLength }).append($li.first().clone());
			for (var i = 0; i < $liLength + 1; i++) { $ul.prepend($ul.children('li').eq(i)); }//倒序处理
		}
		//设置间隔时间
		intervalTime = settings.time + settings.speed;
		//重置$em
		if (settings.emDisplay) {
			for (var i = 0; i < $liLength; i++) {
				emHtml += "<li><a href='javascript:void (0);'>"+(i*1+1)+"</a></li>";
				$(".itemNum-list").eq(i).html(i*1+1);
				var ImgWidth =$(".photoItem-cont").eq(i).find("img").outerWidth();
				var ImgHeight =$(".photoItem-cont").eq(i).find("img").outerHeight();
				var $PHParH = $(".photoCarousel").outerHeight();
				var $PHcontH = $(".photoItem-cont").eq(i).outerHeight();
				var $posHeight = ($PHcontH > $PHParH)?($PHcontH/2):$PHcontH;
				var $posTop = "-"+($posHeight/2)+"px";
				var $posPTop = "-"+($PHParH/2)+"px";
				var $posImgTop = "-"+(ImgHeight/2)+"px";
				var $posWid = "-"+($(".photoItem-cont").eq(i).outerWidth()/2)+"px";
				if($Width < ImgWidth){
					$(".photoItem-cont").eq(i).css({ "height": $posHeight, "overflow": "hidden","position":"absolute","top":"50%","margin-top":$posTop});
					$(".photoItem-cont").eq(i).find(".photoItem").css({ "height": $posHeight, "overflow": "hidden","width":$Width});
					$(".photoItem-cont").eq(i).find("img").css({"width":"100%"});
					
				}else{
					$(".photoItem-cont").eq(i).css({ "height": $PHParH, "overflow": "hidden","position":"absolute","top":"50%","margin-top":$posPTop});
					$(".photoItem-cont").eq(i).find(".photoItem").css({ "height": $PHParH, "overflow": "hidden","width":$Width});
					
				}
				if($Height>ImgHeight){
					$(".photoItem-cont").eq(i).css({ "height": ImgHeight, "overflow": "hidden","position":"absolute","top":"50%","margin-top":$posImgTop});
					$(".photoItem-cont").eq(i).find(".photoItem").css({ "height": ImgHeight, "overflow": "hidden","width":$Width});
				}else{
					$(".photoItem-cont").eq(i).css({ "height": $PHParH, "overflow": "hidden","position":"absolute","top":"50%","margin-top":$posPTop});
					$(".photoItem-cont").eq(i).find(".photoItem").css({ "height": $PHParH, "overflow": "hidden","width":$Width});
				}
			}
			$span.html(emHtml);
			//$span.find("#endListId").before(emHtml);
			//最后一页显示完毕以后显示推荐页
			//$("#endListId").find("a").html($liLength+1);
			$em = $span.children('li');
			$em.eq(0).addClass(settings.classname);
			$(".itemNum-ord").html($liLength);
		}
		//各个切换状态的调用方法
		function display_fn(_index) {//切换
			$li.eq(_index).css('display', 'block').siblings().hide();
			if (settings.emDisplay) {
				$em.eq(_index).addClass(settings.classname).siblings().removeClass(settings.classname);
			}
		}
		function fade_fn(_index) {//渐变
			$li.eq(_index).stop().fadeTo(settings.speed, 1, function () {
				$(this).css({ "z-index": '2' });
			}).siblings().stop().fadeTo(settings.speed, 0, function () {
				$(this).css({ "z-index": '1' });
			});
			if (settings.emDisplay) { $em.eq(_index).addClass(settings.classname).siblings().removeClass(settings.classname); }
			var $sl = $em.eq(_index).position().left;
			var $k=0;
			if($sl>210){
				$k=_index-7;
				$(".j-showNumTotal").animate({left:-35*$k},500);
			}
		}
		function acrossRoll_fn(_index) {//横向左右循环
			$ul.stop().animate({ "left": _index * $Width * (-1) }, settings.speed, function () { pageSign = 0; });
			if (settings.emDisplay) { $em.eq(_index).addClass(settings.classname).siblings().removeClass(settings.classname); }
		}
		function leftRoll_fn(_index) {//左循环
			if (_index == $liLength) { emIndex = 0; } else { emIndex = _index; }
			$ul.stop().animate({ "left": _index * (-1) * $Width }, settings.speed, function () { pageSign = 0; });
			if (settings.emDisplay) { $span.children('li').eq(emIndex).addClass(settings.classname).siblings().removeClass(settings.classname); }
		}
		function rightRoll_fn(_index) {//右循环
			if (_index == $liLength) { emIndex = 0; } else { emIndex = _index; }
			$ul.stop().animate({ "left": ($liLength - _index) * (-1) * $Width }, settings.speed, function () { pageSign = 0; });
			if (settings.emDisplay) { $span.children('li').eq(emIndex).addClass(settings.classname).siblings().removeClass(settings.classname); }
		}
		function verticalRoll_fn(_index) {//竖向上下循环
			$ul.stop().animate({ "top": _index * $Height * (-1) }, settings.speed, function () { pageSign = 0; });
			if (settings.emDisplay) { $em.eq(_index).addClass(settings.classname).siblings().removeClass(settings.classname); }
		}
		function topRoll_fn(_index) {//上循环
			if (_index == $liLength) { emIndex = 0; } else { emIndex = _index; }
			$ul.stop().animate({ "top": _index * (-1) * $Height }, settings.speed, function () { pageSign = 0; });
			if (settings.emDisplay) {$span.children('li').eq(emIndex).addClass(settings.classname).siblings().removeClass(settings.classname);}
		}
		function bottomRoll_fn(_index) {//下循环
			if (_index == $liLength) { emIndex = 0; } else { emIndex = _index; }
			$ul.stop().animate({ "top": ($liLength - _index) * (-1) * $Height }, settings.speed, function () { pageSign = 0; });
			if (settings.emDisplay) { $span.children('li').eq(emIndex).addClass(settings.classname).siblings().removeClass(settings.classname); }
		}
		//定时器调用的轮播切换的方法
		function Time() {
			if (settings.switchover == 'display') {
				if (index == $liLength - 1) { index = 0; } else { index = index + 1; }
				display_fn(index);
			}else if (settings.switchover == 'fade') {
				if (index == $liLength - 1) { index = 0; } else { index = index + 1; }
				fade_fn(index);
			} else if (settings.switchover == 'acrossRoll') {
				if (index == $liLength - 1) { direction = -1; } else if (index == 0) { direction = 1 }
				index = index + direction;
				acrossRoll_fn(index);
			} else if (settings.switchover == 'leftRoll') {
				if (index == $liLength) {index = 0;$ul.css("left", 0);}
				index = index + 1;
				leftRoll_fn(index);
			} else if (settings.switchover == 'rightRoll') {
				if (index == $liLength) { index = 0; $ul.css("left", $Width * (-1) * $liLength); }
				index = index + 1;
				rightRoll_fn(index);
			}else if (settings.switchover == 'verticalRoll') {
				if (index == $liLength - 1) { direction = -1; } else if (index == 0) { direction = 1 }
				index = index + direction;
				verticalRoll_fn(index);
			} else if (settings.switchover == 'topRoll') {
				if (index == $liLength) { index = 0; $ul.css("top", 0); }
				index = index + 1;
				topRoll_fn(index);
			} else if (settings.switchover == 'bottomRoll') {
				if (index == $liLength) { index = 0; $ul.css("top", $Height * (-1) * $liLength); }
				index = index + 1;
				bottomRoll_fn(index);
			}
		}

		if ($liLength > 1) {
			//开启定时器

			//鼠标移入移出序号点的切换
			if (settings.emDisplay) {
				$em.mouseover(function () {
					var $pleft = $(this).offset().left;
					var $lenNum =$liLength;
					index = $(this).index();
					var $imgCont = $li.eq(index).find(".photoImg").html();
					$(".newsImgItem-thum").css({"left":$pleft,"margin-left":"-34px"}).show();
					$(".thum-img-tips").css({"left":$pleft+7});
					if($lenNum > index){
						$(".newsImgItem-thum-img").html($imgCont);
					}else{
						$(".newsImgItem-thum").hide();
					}

				}).mouseout(function () {
					$(".newsImgItem-thum").hide();
				});
			}
			if (settings.emDisplay) {
				$em.click(function () {
					clearInterval(changeTime);
					index = $(this).index();
					if (settings.switchover == 'display') {
					 display_fn(index);
					 } else if (settings.switchover == 'fade') {
					 fade_fn(index);
					 } else if (settings.switchover == 'acrossRoll') {
					 acrossRoll_fn(index);
					 } else if (settings.switchover == 'leftRoll') {
					 leftRoll_fn(index);
					 } else if (settings.switchover == 'rightRoll') {
					 rightRoll_fn(index);
					 } else if (settings.switchover == 'verticalRoll') {
					 verticalRoll_fn(index);
					 } else if (settings.switchover == 'topRoll') {
					 topRoll_fn(index);
					 } else if (settings.switchover == 'bottomRoll') {
					 bottomRoll_fn(index);
					 }
				})
			}
			//下一页翻页的设置
			if (settings.page) {
				//翻页点击切换
				function pageClick(pageDirection) {  //pageDirection=‘prev’ ||'next'
					var index_1, index_2, num_1, num_2;
					var $pkey = true;
					if (pageDirection == 'next') {
						index_1 = $liLength - 1;
						index_2 = 0;
						num_1 = 1;
						num_2 = -1;
						$pkey = true;
					} else if (pageDirection == 'prev') {
						index_1 = 0;
						index_2 = $liLength - 1;
						num_1 = -1;
						num_2 = 1;
						$pkey=false;
					}
					if (settings.switchover == 'display') {
						if (index == index_1) { index = index_2; } else { index = index + num_1; }
						display_fn(index);
					} else if (settings.switchover == 'fade') {
						if (index == index_1) {
							if($pkey){
								$(".mainContent").addClass("fn-dn");
								$(".newsImg-suggest").removeClass("fn-dn");
							}
							index = index_2;
						} else { index = index + num_1; }
						fade_fn(index);
					} else if (settings.switchover == 'acrossRoll') {
						if (pageSign == 0) {
							pageSign = 1;
							if (index == index_1) { pageSign = 0; return false; } else { index = index + num_1 }
							acrossRoll_fn(index);
						}
					} else if (settings.switchover == 'leftRoll') {
						if (pageSign == 0) {
							pageSign = 1;
							if (pageDirection == 'next') {
								if (index == $liLength) { index = 0; $ul.css("left", 0); }
							} else if (pageDirection == 'prev') {
								if (index == 0) { index = $liLength; $ul.css("left", ($liLength) * -1 * $Width); }
							}
							index = index + num_1;
							leftRoll_fn(index);
						}
					} else if (settings.switchover == 'rightRoll') {
						if (pageSign == 0) {
							pageSign = 1;
							if (pageDirection == 'next') {
								if (index == $liLength) { index = 0; $ul.css("left", $Width * (-1) * $liLength); }
							} else if (pageDirection == 'prev') {
								if (index == 0) { index = $liLength; $ul.css("left", 0); }
							}
							index = index + num_1;
							rightRoll_fn(index);
						}
					} else if (settings.switchover == 'verticalRoll') {
						if (pageSign == 0) {
							pageSign = 1;
							if (index == index_1) { pageSign = 0; return false; } else { index = index + num_1; }
							verticalRoll_fn(index);
						}
					} else if (settings.switchover == 'topRoll') {
						if (pageSign == 0) {
							pageSign = 1;
							if (pageDirection == 'next') {
								if (index == $liLength) { index = 0; $ul.css("top", 0); }
							} else if (pageDirection == 'prev') {
								if (index == 0) { index = $liLength; $ul.css("top", ($liLength) * -1 * $Height); }
							}
							index = index + num_1;
							topRoll_fn(index);
						}
					} else if (settings.switchover == 'bottomRoll') {
						if (pageSign == 0) {
							pageSign = 1;
							if (pageDirection == 'next') {
								if (index == $liLength) { index = 0; $ul.css("top", $Height * (-1) * $liLength); }
							} else if (pageDirection == 'prev') {
								if (index == 0) { index = $liLength; $ul.css("top", 0); }
							}
							index = index + num_1;
							bottomRoll_fn(index);
						}
					}
				}
				//下一页翻页的设置
				$this.children(settings.page_next).attr('href', 'javascript:void(0)').mouseover(function () {
					//clearInterval(changeTime);
				}).mouseout(function () {
					//changeTime = setInterval(Time, intervalTime);
				}).click(function () {
					pageClick('next');
				});
				//上一页翻页的设置
				$this.children(settings.page_prev).attr('href', 'javascript:void(0)').mouseover(function () {
					//clearInterval(changeTime);
				}).mouseout(function () {
					//changeTime = setInterval(Time, intervalTime);
				}).click(function () {
					pageClick('prev');
				});
			} else {
				$this.children(settings.page_next).hide();
				$this.children(settings.page_prev).hide();
			}
			if (!settings.auto){
				clearInterval(changeTime);
			}else{
				changeTime = setInterval(Time, intervalTime);
			}
			//鼠标移入移出图片上关闭开启轮播切换
			/*$('.photoCarousel').hover(
				function (e) {
					var $plx = $(this).position().left;
					var $xx = e.originalEvent.x || e.originalEvent.layerX || 0; 
					var $cx = $xx - $plx;
					if($cx > 424){
						$(".next").css({"display":"block"});
					}else{
						$(".prev").css({"display":"block"});
					}
				},
				function () {
					$(".scrollBtn").css({"display":"none"});
				}
			);*/
			$('.photoCarousel').mousemove(function(e){
				var $plx = $(this).position().left;
				var $ply = $(this).position().top;
				var $xx = e.pageX;
				var $yy = e.pageY; 
				var $cx = $xx - $plx;
				var $cy = $yy - $ply;
				if($cx > 470){
					$(".next").css({"display":"block","left":$xx-115,"top":$yy-125});
					$(".prev").css({"display":"none"});
				}else{
					$(".prev").css({"display":"block","left":$xx-80,"top":$yy-125});
					$(".next").css({"display":"none"});
				}
				if($yy>630){
					$(".scrollBtn").css({"display":"none"});
				}
			});
			$('.photoCarousel').mouseout(function(){
				$(".scrollBtn").css({"display":"none"});
			});
			 
		}
	});
};